package pl.kkalisz.android;

import pl.kkalisz.android.model.error.uWindowNotFoundException;
import pl.kkalisz.android.model.item.uItemActionButton;
import pl.kkalisz.android.model.item.interfaces.uActionItemInterface;
import pl.kkalisz.android.model.item.interfaces.uOnClickedListner;
import pl.kkalisz.android.model.window.uWindowBuilder;
import pl.kkalisz.android.model.window.uWindows;
import pl.kkalisz.android.model.window.uWindowResolver;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.ViewGroup;
import android.widget.ProgressBar;

public class MainActivity extends Activity {


    uItemActionButton mButton1;
    uItemActionButton mButton2;
    ProgressBar mProgressBar;
    Context mContext;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mContext = this;
        setContentView(R.layout.main_menu_layout);
        mButton1 = ((uItemActionButton) findViewById(R.id.itemActionButton1));
        mButton2 = ((uItemActionButton) findViewById(R.id.itemActionButton2));
        uWindowResolver.init();

        mButton1.addClickedListner(new uOnClickedListner() {

            public void onClick(uActionItemInterface aActionItem)
            {
                Log.d("kkalisz", "kliknietp");
                uWindowBuilder aBuilder;
               
                try 
                {
                    aBuilder = new uWindowBuilder((Activity) mContext, uWindows.TEST_WINDOW);
                    aBuilder.show();
                } catch (uWindowNotFoundException e) 
                {
                    e.printStackTrace((Activity) mContext);

                }

            }
        });



        mProgressBar = new ProgressBar(this);

        mButton2.addClickedListner(new uOnClickedListner() 
        {

            public void onClick(uActionItemInterface aActionItem) 
            {
                addContentView(mProgressBar,  new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                        ViewGroup.LayoutParams.FILL_PARENT));
                // mProgressBar.setVisibility(View.VISIBLE);

            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }


}
